function deepClone(obj) {
    let result = undefined;
    if (getType(obj) == '[object Object]') {
        result = {};
        for (const [key, value] of Object.entries(obj)) {
            Reflect.set(result, key, deepClone(value));
        }
    } else if (getType(obj) == '[object Array]') {
        result = [];
        for (let item of obj) {
            result.push(deepClone(item));
        }
    } else {
        result = obj;
    }
    return result;
}

/**
 * var number = 1;          [object Number]
 *var string = '123';       [object String]
 var boolean = true;        [object Boolean]
 var und = undefined;       [object Undefined]
 var nul = null;            [object Null]
 var obj = {a: 1}           [object Object]
 var array = [1, 2, 3];     [object Array]
 var date = new Date();     [object Date]
 var error = new Error();   [object Error]
 var reg = /a/g;            [object RegExp]
 var func = function a(){}; [object Function]
 */
function getType(obj) {
    if (obj === undefined) return 'undefined';
    if (obj === null) return 'null';
    return Object.prototype.toString.call(obj);
}

let obj1 = {
    a: {
        c: /a/,
        d: undefined,
        b: null
    },
    b: function () {
        console.log(this.a)
    },
    c: [
        {
            a: 'c',
            b: /b/,
            c: undefined
        },
        'a',
        3
    ]
}
let obj2 = deepClone(obj1);
console.log(obj2);
